﻿namespace NMortgage.UI.Model
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using FluentValidation;

    public class BetaDistributionValidator : AbstractValidator<BetaDistribution>
    {
        #region Constructors

        public BetaDistributionValidator()
        {
            RuleFor(r => r.Alpha).GreaterThan(0d);
            RuleFor(r => r.Beta).GreaterThan(0d);

            RuleFor(r => r.Minimum).GreaterThan(0d);
            RuleFor(r => r.Maximum).LessThan(30d);

            RuleFor(r => r.Minimum)
                .LessThan(r => r.Maximum)
                .WithLocalizedMessage(() => Properties.Resources.ValidationError_MinLessThanMax);

            RuleFor(r => r.Maximum)
                .GreaterThan(r => r.Minimum)
                .WithLocalizedMessage(() => Properties.Resources.ValidationError_MinLessThanMax);
        }

        #endregion Constructors
    }

    public sealed class FixedRateValidator : AbstractValidator<FixedRate>
    {
        #region Constructors

        public FixedRateValidator()
        {
            RuleFor(r => r.Rate).GreaterThan(0d);
            RuleFor(r => r.Rate).LessThanOrEqualTo(30d);
        }

        #endregion Constructors
    }

    public class NormalDistributionValidator : AbstractValidator<NormalDistribution>
    {
        #region Constructors

        public NormalDistributionValidator()
        {
            RuleFor(r => r.Mean).GreaterThan(0d);
            RuleFor(r => r.Mean).LessThan(30d);
            RuleFor(r => r.StdDev).GreaterThan(0d);

            RuleFor(r => r.StdDev)
                .LessThanOrEqualTo(r => r.Mean / 3d)
                .WithLocalizedMessage(() => Properties.Resources.ValidationError_StdDevRatio);
        }

        #endregion Constructors
    }

    public class UniformDistributionValidator : AbstractValidator<UniformDistribution>
    {
        #region Constructors

        public UniformDistributionValidator()
        {
            RuleFor(r => r.Minimum).GreaterThan(0d);
            RuleFor(r => r.Maximum).LessThan(30d);

            RuleFor(r => r.Minimum)
                .LessThan(r => r.Maximum)
                .WithLocalizedMessage(() => Properties.Resources.ValidationError_MinLessThanMax);

            RuleFor(r => r.Maximum)
                .GreaterThan(r => r.Minimum)
                .WithLocalizedMessage(() => Properties.Resources.ValidationError_MinLessThanMax);
        }

        #endregion Constructors
    }
}